"""
提示词模板数据模式
"""

from typing import Optional, List, Dict, Any
from datetime import datetime
from pydantic import BaseModel


class PromptTemplateBase(BaseModel):
    """提示词模板基础模式"""
    name: str
    description: Optional[str] = None
    content: str
    category: Optional[str] = None
    tags: Optional[List[str]] = None
    is_public: bool = False


class PromptTemplateCreate(PromptTemplateBase):
    """创建提示词模板模式"""
    pass


class PromptTemplateUpdate(BaseModel):
    """更新提示词模板模式"""
    name: Optional[str] = None
    description: Optional[str] = None
    content: Optional[str] = None
    category: Optional[str] = None
    tags: Optional[List[str]] = None
    is_active: Optional[bool] = None
    is_public: Optional[bool] = None


class PromptTemplateResponse(PromptTemplateBase):
    """提示词模板响应模式"""
    id: int
    variables: Optional[List[str]] = None
    is_active: bool
    usage_count: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True


class PromptTemplateRenderRequest(BaseModel):
    """提示词模板渲染请求模式"""
    template_id: int
    variables: Dict[str, str]


class PromptTemplateRenderResponse(BaseModel):
    """提示词模板渲染响应模式"""
    rendered_content: str
    variables_used: List[str]
    variables_missing: List[str]


class PromptTemplateSearchRequest(BaseModel):
    """提示词模板搜索请求模式"""
    query: str
    category: Optional[str] = None
    tags: Optional[List[str]] = None
    is_public: Optional[bool] = None
